//
//  YWTopicDetailMessageCell.m
//  网易新闻
//
//  Created by Yeewii@hotmail.com on 16/6/18.
//  Copyright © 2016年 Yeewii@hotmail.com. All rights reserved.
//

#import "YWTopicDetailMessageCell.h"
#import <UIImageView+WebCache.h>
#import "NSObject+Tool.h"


@implementation YWTopicDetailMessageCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpViews];
    }
    return self;
}


-(void)setUpViews
{
    _iconImage               = [UIImageView new];
    _nameLabel               = [UILabel new];
    _contentLabel            = [UILabel new];
    _picView                 = [YWTopicPicView new];
    _timeLabel               = [UILabel new];
    _timeLabel.font          = [UIFont systemFontOfSize:12];
    _repLabel                = [UILabel new];
    _repLabel.font           = [UIFont systemFontOfSize:12];
    _goodLable               = [UILabel new];
    _goodLable.font          = [UIFont systemFontOfSize:12];
    _goodLable.textAlignment = NSTextAlignmentRight;

    [self.contentView addSubview:_iconImage];
    [self.contentView addSubview:_nameLabel];
    [self.contentView addSubview:_contentLabel];
    [self.contentView addSubview:_picView];
    [self.contentView addSubview:_timeLabel];
    [self.contentView addSubview:_repLabel];
    [self.contentView addSubview:_goodLable];
    
    
    
    _iconImage.sd_layout
    .leftSpaceToView(self.contentView,10)
    .topSpaceToView(self.contentView,20)
    .heightIs(30)
    .widthIs(30);
    
    _nameLabel.sd_layout
    .leftSpaceToView(_iconImage,10)
    .centerYEqualToView(_iconImage)
    .heightIs(20)
    .widthIs(100);
    
    _contentLabel.sd_layout
    .leftEqualToView(_nameLabel)
    .topSpaceToView(_nameLabel,10)
    .rightSpaceToView(self.contentView,20)
    .autoHeightRatio(0);
    
    _picView.sd_layout
    .leftEqualToView(self.contentView);
    
    
    _timeLabel.sd_layout
    .leftSpaceToView(self.contentView,10)
    .heightIs(30)
    .widthIs(150);
    
    _repLabel.sd_layout
    .topEqualToView(_timeLabel)
    .leftSpaceToView(_timeLabel,50)
    .heightIs(30);
    
    _goodLable.sd_layout
    .topEqualToView(_repLabel)
    .rightSpaceToView(self.contentView,10)
    .widthIs(100)
    .heightIs(30);
    
}

-(void)setModel:(YWTopicDetailHotList *)model
{
    _model             = model;
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:_model.userHeadPicUrl]];
    _nameLabel.text    = _model.userName;
    _contentLabel.text = _model.content;
    _timeLabel.text    = [NSObject TimespStrTurnDate:_model.cTime];
    _repLabel.text     = [NSString stringWithFormat:@"%d",_model.discussCount];
    _goodLable.text    = [NSString stringWithFormat:@"%d",_model.supportCount];
    _picView.picDic    = _model.ext;
    _picView.picArray  = _model.picurl;
    _repLabel.text     = [NSString stringWithFormat:@"%d支持",_model.discussCount];
    _goodLable.text    = [NSString stringWithFormat:@"%d点赞",_model.supportCount];



    _picView.sd_layout
    .topSpaceToView(_contentLabel,10);

    _timeLabel.sd_layout
    .topSpaceToView(_picView,20);


    [self setupAutoHeightWithBottomViewsArray:@[_picView,_timeLabel] bottomMargin:10];

    
}


@end
